package edu.sctu.zhoumengxue.day201506.day20150628.practice;


import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by user12 on 2015/6/28.
 */
public class PostJson {

    public String getJson(String path){

        int count;
        String string="";
        byte[] bytes = new byte[1024];

        try {
            URL url = new URL(path);
            try {
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.connect();

                InputStream in = connection.getInputStream();
                while ((count = in.read(bytes))!=-1){

                    string = new String(bytes,0,count);

                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }

        return string;

    }
}
